Write characters to a file

This example writes eight characters from a 13-element array to a file, beginning at the third element of the array.

C# .NET

public static String DoTest()
{
         try
         {
                  FileMode mode = FileMode.OpenOrCreate;
                  FileStream sb = new FileStream("c:\\MyFile.txt", mode);
                  char[] b = {'a','b','c','d','e','f','g','h','i','j','k','l','m'};
                  StreamWriter sw = new StreamWriter(sb);
                  sw.Write(b, 3, 8);
                  sw.Close();
         }
         catch(Exception e)
         {
                  return ("Error in eriting stream, cause: " + e.Message);
         }
         return "Stream was created successfully";
         
         System.IO.Path
}

 

Blaze++ .NET

static String DoTest()
{
         try
         {
                  FileMode mode = FileMode::OpenOrCreate;
                  FileStream sb("c:\\MyFile.txt", mode);
                  TCHAR _b[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m'};
                  charA b(_b, 13);
                  StreamWriter sw(sb);
                  sw.Write(b, 3, 8);
                  sw.Close();
         }
         catch(Exception e)
         {
                  return ("Error in eriting stream, cause: " + e.Message);
         }
         return "Stream was created successfully";         
}